package cays.student.controller;

import cays.student.service.CourseService;
import cays.student.vo.Course;
import cays.student.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 课程信息控制类
 *
 * @author Chai yansheng
 * @create 2019/8/30
 **/
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;
    @GetMapping("/get/{cno}")
    ResultVO getCourseByCno(@PathVariable("cno") String cno) {
        return new ResultVO("0", courseService.getCourseByCno(cno));
    }
    @GetMapping("/list")
    ResultVO getAllCourse() {
        return new ResultVO("0", courseService.getAllCourse());
    }
    @PostMapping("/update")
    ResultVO updateCourse(@RequestBody Course course) {
        return new ResultVO("0", courseService.updateCourseByCno(course));
    }
    @PostMapping("/insert")
    ResultVO insertCourse(@RequestBody Course course) {
        return new ResultVO("0", courseService.insertCourse(course));
    }
    @GetMapping("/delete/{cno}")
    ResultVO deleteCourse(@PathVariable("cno") String cno) {
        return new ResultVO("0", courseService.deleteCourseByCno(cno));
    }
}
